﻿<visi:VisiPage x:Class="VNet.VisiSuite.VisiAdmin.Views.ProductView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:visi="clr-namespace:VNet.VisiSuite.VisiAdmin.Controls"
        xmlns:vm="clr-namespace:VNet.VisiSuite.VisiAdmin.ViewModels" xmlns:c="clr-namespace:VNet.VisiSuite.VisiAdmin.Controls"
        xmlns:vuc="clr-namespace:VNet.VisiSuite.Controls;assembly=VNet.VisiSuite.Controls" xmlns:converter="clr-namespace:VNet.VisiSuite.VisiAdmin.Common.Converters"
               xmlns:dg="http://infragistics.com/DataPresenter"
               xmlns:igDock="http://infragistics.com/DockManager"
               xmlns:ig="http://schemas.infragistics.com/xaml"
               xmlns:system="clr-namespace:System;assembly=mscorlib"
               DataContext="{DynamicResource ProductViewModel}" mc:Ignorable="d" d:DesignHeight="497.449" d:DesignWidth="891.992">
    <visi:VisiPage.Resources>
        <vm:ProductViewModel x:Key="ProductViewModel" />
        <converter:MultiBoolConverter x:Key="MultiBoolConverter" />
        <converter:ObjectNullVisibilityConverter x:Key="ObjectNullVisibilityConverter" />
        <converter:InvertBooleanVisibilityConverter x:Key="InvertBooleanVisibilityConverter" />
    </visi:VisiPage.Resources>
    <!--   <vuc:BusyIndicator> -->
    <Grid Focusable="False" Background="{StaticResource WhiteColor}">
        <igDock:XamDockManager PaneDragStarting="PaneDragStarting">
            <igDock:ContentPane Style="{StaticResource NoHeaderPane}">
                <Grid VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="*" />
                        <RowDefinition Height="42" />
                    </Grid.RowDefinitions>

                    <!--Header-->
                    <c:Header2Control Grid.Row="0" Title="{Binding PageTitle}" LeftMenuIcons="{Binding TopLeftButtonIcons}" RightMenuIcons="{Binding TopRightButtonIcons}" />

                    <!--Body-->
                    <Grid Grid.Row="1">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="*" />
                        </Grid.RowDefinitions>

                        <TextBlock Style="{StaticResource CaptionTextBlockStyle}" Grid.Row="0"
                                    Text="Select a product from the list below to edit it. Use the Add button to the right to add a new product" />

                        <Grid Grid.Row="1">
                            <dg:XamDataPresenter DataSource="{Binding Path=Products}" ActiveDataItem="{Binding SelectedProduct}" Style="{StaticResource XamDataPresenterStyle}">
                                <dg:XamDataPresenter.FieldSettings>
                                    <dg:FieldSettings AllowEdit="False" AllowRecordFiltering="True" LabelClickAction="Nothing" />
                                </dg:XamDataPresenter.FieldSettings>
                                <dg:XamDataPresenter.FieldLayoutSettings>
                                    <dg:FieldLayoutSettings HeaderPrefixAreaDisplayMode="FieldChooserButton" AutoGenerateFields="False" />
                                </dg:XamDataPresenter.FieldLayoutSettings>
                                <dg:XamDataPresenter.FieldLayouts>
                                    <dg:FieldLayout>
                                        <dg:Field Name="Sku" Label="SKU" Width="*">
                                            <dg:Field.Settings>
                                                <dg:FieldSettings LabelClickAction="SortByOneFieldOnly" />
                                            </dg:Field.Settings>
                                        </dg:Field>
                                        <dg:Field Name="Description" Label="Description" Width="*">
                                            <dg:Field.Settings>
                                                <dg:FieldSettings LabelClickAction="SortByOneFieldOnly" />
                                            </dg:Field.Settings>
                                        </dg:Field>
                                        <dg:Field Name="Revision" Label="Revision" Width="100">
                                            <dg:Field.Settings>
                                                <dg:FieldSettings LabelClickAction="SortByOneFieldOnly" />
                                            </dg:Field.Settings>
                                        </dg:Field>
                                        <dg:Field Name="PartTime" Label="Part Time (sec)"  Width="150" >
                                            <dg:Field.Settings>
                                                <dg:FieldSettings LabelClickAction="SortByOneFieldOnly" />
                                            </dg:Field.Settings>
                                        </dg:Field>
                                        <dg:Field Name="SetupTime" Label="Setup Time (sec)"  Width="150" >
                                            <dg:Field.Settings>
                                                <dg:FieldSettings LabelClickAction="SortByOneFieldOnly" />
                                            </dg:Field.Settings>
                                        </dg:Field>
                                        <dg:Field Name="CycleTime" Label="Cycle Time (sec)"  Width="150" >
                                            <dg:Field.Settings>
                                                <dg:FieldSettings LabelClickAction="SortByOneFieldOnly" />
                                            </dg:Field.Settings>
                                        </dg:Field>
                                        <dg:Field Name="LoadUnloadTime" Label="Load Unload (sec)"  Width="150" >
                                            <dg:Field.Settings>
                                                <dg:FieldSettings LabelClickAction="SortByOneFieldOnly" />
                                            </dg:Field.Settings>
                                        </dg:Field>
                                        <dg:Field Name="IsEnabled" Label="Enabled"  Width="100">
                                            <dg:Field.Settings>
                                                <dg:FieldSettings LabelClickAction="SortByOneFieldOnly" CellValuePresenterStyle="{StaticResource CheckBoxStyleGrid}" />
                                            </dg:Field.Settings>
                                        </dg:Field>
                                        <dg:Field Visibility="Collapsed" Name="CreatedByUser" Label="Created By" />
                                        <dg:Field Visibility="Collapsed" Name="CreatedDate" Label="Created Date" />
                                        <dg:Field Visibility="Collapsed" Name="LastUpdatedByUser" Label="Last Updated By" />
                                        <dg:Field Visibility="Collapsed" Name="LastUpdatedDate" Label="Last Updated Date" />
                                    </dg:FieldLayout>
                                </dg:XamDataPresenter.FieldLayouts>
                            </dg:XamDataPresenter>
                        </Grid>
                    </Grid>
                    <!--Footer-->
                    <ContentControl Grid.Row="2" Template="{StaticResource FooterTemplate}" />
                </Grid>
            </igDock:ContentPane>

            <igDock:XamDockManager.Panes>
                <igDock:SplitPane igDock:XamDockManager.InitialLocation="DockedRight" Width="325" SplitterOrientation="Horizontal">
                    <igDock:ContentPane Header="Product Properties" Style="{StaticResource RightPaneStyle}">
                        <Grid VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Visibility="{Binding CloneSelectedProduct, Converter={StaticResource ObjectNullVisibilityConverter}}">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="*" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>

                            <ig:XamPropertyGrid Grid.Row="1"  SelectedObject="{Binding CloneSelectedProduct}" ScrollBarVisibility="Auto" FilterAreaVisibility="Collapsed" >
                                <ig:XamPropertyGrid.ItemFilters>
                                    <ig:PropertyGridConditionGroup LogicalOperator="Or" >
                                        <ig:PropertyGridComparisonCondition  Operator="Equals"  OperandSource="CategoryName" Value="Properties" ></ig:PropertyGridComparisonCondition>
                                        <ig:PropertyGridComparisonCondition  Operator="Equals"  OperandSource="CategoryName" Value="Update History" ></ig:PropertyGridComparisonCondition>
                                    </ig:PropertyGridConditionGroup>
                                </ig:XamPropertyGrid.ItemFilters>
                                <ig:XamPropertyGrid.EditorDefinitions>
                                    <ig:PropertyGridEditorDefinition Category="Update History">
                                        <ig:PropertyGridEditorDefinition.EditTemplate>
                                            <DataTemplate>
                                                <TextBlock Text ="{Binding Value}" Style="{StaticResource PropertyDataTextBlockStyle}"/>
                                            </DataTemplate>
                                        </ig:PropertyGridEditorDefinition.EditTemplate>
                                    </ig:PropertyGridEditorDefinition>
                                </ig:XamPropertyGrid.EditorDefinitions>
                            </ig:XamPropertyGrid>

                            <StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Center">
                                <Button Content="Save" Style="{StaticResource PropertyButtonStyle}" Command="{Binding SaveCommand}">
                                    <Button.IsEnabled>
                                        <MultiBinding Converter="{StaticResource MultiBoolConverter}">
                                            <Binding Path="CloneSelectedProduct.IsChange" Source="{StaticResource ProductViewModel}"/>
                                            <Binding Path="CloneSelectedProduct.Sku" Source="{StaticResource ProductViewModel}" />
                                        </MultiBinding>
                                    </Button.IsEnabled>
                                </Button>
                                <Button Content="Cancel" Style="{StaticResource PropertyButtonStyle}" Command="{Binding CancelCommand}" IsEnabled="{Binding CloneSelectedProduct.IsCancelEnable}" />
                                <Button Style="{StaticResource PropertyButtonStyle}" Content="Delete" Command="{Binding DeleteCommand}"
                                                Visibility="{Binding CloneSelectedProduct.IsAddNew,Converter={StaticResource InvertBooleanVisibilityConverter},ConverterParameter=Collapsed}" />
                            </StackPanel>

                            <StackPanel Grid.Row="3">
                                <vuc:ValidationSummary x:Name="ValidationSummary" />
                                <TextBlock Text="{Binding CloneSelectedProduct.ErrorMessage}" Style="{StaticResource ErrorTextBlockStyle}" />
                            </StackPanel>
                        </Grid>
                    </igDock:ContentPane>
                </igDock:SplitPane>
            </igDock:XamDockManager.Panes>
        </igDock:XamDockManager>
    </Grid>
    <!--  </vuc:BusyIndicator> -->
</visi:VisiPage>
